<html>
<head><meta charset="utf-8"><title>Windows thread_local_dtor (formerly fast_thread_local) · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Windows.20thread_local_dtor.20(formerly.20fast_thread_local).html">Windows thread_local_dtor (formerly fast_thread_local)</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="203921501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Windows%20thread_local_dtor%20%28formerly%20fast_thread_local%29/near/203921501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Windows.20thread_local_dtor.20(formerly.20fast_thread_local).html#203921501">(Jul 15 2020 at 06:51)</a>:</h4>
<p>Windows is <a href="https://github.com/rust-lang/rust/blob/master/src/libstd/sys/windows/thread_local_dtor.rs">using the default <code>thread_local_dtor</code> implementation</a> which <a href="https://github.com/rust-lang/rust/blob/master/src/libstd/sys_common/thread_local_dtor.rs">falls back to using a TLS key with associated dtor</a>. This is despite the fact that TLS keys with dtor are actually <a href="https://github.com/rust-lang/rust/blob/567ad7455d5f25f6b38d2fded1cb621e0c34a48b/src/libstd/sys/windows/thread_local_key.rs#L192">implemented with a global dtor</a>. This looks like Windows could have a more efficient <code>thread_local_dtor::register_dtor</code> that avoids <code>TlsAlloc</code> (similar to what Unix already does). Is there any particular reason why this isn't the case?</p>



<a name="203921632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Windows%20thread_local_dtor%20%28formerly%20fast_thread_local%29/near/203921632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Windows.20thread_local_dtor.20(formerly.20fast_thread_local).html#203921632">(Jul 15 2020 at 06:54)</a>:</h4>
<p>(I am not entirely sure why on Unix we avoid using the fallback implementation, but it seems like it is more efficient for some reason.)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>